package com.lz.sports.bean

import android.os.Parcel
import android.os.Parcelable
import com.lz.library.proguard.IProguardField
import com.google.gson.annotations.Expose
import com.google.gson.annotations.SerializedName

//考试区域
class ExamArea() : ParcelableString, IProguardField {

    //唯一值 其它关联表的外键
    @Expose
    var id: Int = 0

    @Expose
    var areaId: Int = 0

    //编号
    @Expose
    var examAreaCode: String = ""

    //项目名称
    @Expose
    var examAreaName: String = ""

    //计划ID
    @Expose
    var examPlanId: Int = 0

    //城市ID
    @Expose
    var cityId: Int = 0

    //省ID
    @Expose
    var provinceId: Int = 0

    //创建时间
    @Expose
    var createTime: Long = 0L

    //更新时间
    @Expose
    var updateTime: Long = 0L

    //考点列表
    @Expose
    @SerializedName("busExamSiteDTOList")
    var examSiteList: List<ExamSite>? = null

    fun examSite(siteId: Int): ExamSite? {
        for (examSite in this.examSiteList!!) {
            if (examSite.id == siteId) {
                return examSite
            }
        }
        return null
    }

    override fun str(): String = examAreaCode

    override fun equals(other: Any?): Boolean = other === this || (other is ExamArea && other.id == id)

    constructor(parcel: Parcel) : this() {
        id = parcel.readInt()
        areaId = parcel.readInt()
        examAreaCode = parcel.readString()!!
        examAreaName = parcel.readString()!!
        examPlanId = parcel.readInt()
        cityId = parcel.readInt()
        provinceId = parcel.readInt()
        createTime = parcel.readLong()
        updateTime = parcel.readLong()
        examSiteList = parcel.createTypedArrayList(ExamSite.CREATOR)
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeInt(id)
        parcel.writeInt(areaId)
        parcel.writeString(examAreaCode)
        parcel.writeString(examAreaName)
        parcel.writeInt(examPlanId)
        parcel.writeInt(cityId)
        parcel.writeInt(provinceId)
        parcel.writeLong(createTime)
        parcel.writeLong(updateTime)
        parcel.writeTypedList(examSiteList)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<ExamArea> {
        override fun createFromParcel(parcel: Parcel): ExamArea {
            return ExamArea(parcel)
        }

        override fun newArray(size: Int): Array<ExamArea?> {
            return arrayOfNulls(size)
        }
    }
}